{% extends 'admin-v2/resource-settlement/layout.html.twig' %}

{% set menu="admin_v2_resource_settlement_balance" %}

{% block main %}
  <div class="well mbm ptl pbl">
    <div class="row admin-data">
      <div class="col-md-3 text-center">
        <div class="admin-data__value">{{ merchant.balance|default(0) / 100|currency }}</div>
        <div class="admin-data__explain">{{ 'admin_v2.app_center.resource_settlement.balance'|trans }}</div>
      </div>
      <div class="col-md-offset-3 col-md-6">
        <div class="resource-settlement-float-center">
          <span>{{ 'admin_v2.app_center.resource_settlement.debt'|trans }}：</span>
          {{ merchant.debt_sum|default(0) / 100 }}
          <a href="{{ path('admin_v2_resource_settlement_order') }}">{{ 'admin_v2.app_center.resource_settlement.more'|trans }}
            >>></a>
        </div>
      </div>
    </div>
  </div>

  <form class="form-inline well well-sm mbm" action="" method="get" novalidate>
    <div class="form-group">
      <label class="control-label">{{ 'admin_v2.app_center.resource_settlement.balance.deal_time'|trans }}</label>
      <input class="form-control" type="text" id="startTime" name="startTime"
             value="{{ app.request.query.get('startTime') }}"
             placeholder="{{ 'admin_v2.app_center.resource_settlement.start_time'|trans }}" autocomplete="off">
      -
      <input class="form-control" type="text" id="endTime" name="endTime"
             value="{{ app.request.query.get('endTime') }}"
             placeholder="{{ 'admin_v2.app_center.resource_settlement.end_time'|trans }}" autocomplete="off">
    </div>

    <div class="form-group">
      <label for="title"
             class="control-label">{{ 'admin_v2.app_center.resource_settlement.order.title'|trans }}</label>
      <input class="form-control" type="text" id="title" name="title" value="{{ app.request.query.get('title') }}">
    </div>

    <button class="btn btn-primary">{{ 'form.btn.search'|trans }}</button>
  </form>

  <table class="table">
    <thead>
    <tr>
      <th>{{ 'admin_v2.app_center.resource_settlement.balance.sn'|trans }}</th>
      <th>{{ 'admin_v2.app_center.resource_settlement.balance.created_time'|trans }}</th>
      <th>{{ 'admin_v2.app_center.resource_settlement.balance.title'|trans }}</th>
      <th>{{ 'admin_v2.app_center.resource_settlement.balance.amount'|trans }}</th>
      <th>{{ 'admin_v2.app_center.resource_settlement.balance.balance'|trans }}</th>
      <th>{{ 'admin_v2.app_center.resource_settlement.balance.action'|trans }}</th>
      <th>{{ 'operation'|trans }}</th>
    </tr>
    </thead>
    <tbody>
    {% for item in items %}
      <tr>
        <td>{{ item.sn|default('-') }}</td>
        <td>{{ item.created_time|date_format('Y-m-d H:i:s')|default('-') }}</td>
        <td>
          {% if item.action == 'recharge' %}
            {{ 'admin_v2.app_center.resource_settlement.balance.recharge'|trans }}
          {% else %}
            {{ item.title|default('-') }}
          {% endif %}
        </td>
        <td>
          {% if item.type == 'inflow' %}
            <span class="text-success">+ {{ item.amount|default(0) / 100|currency }}</span>
          {% elseif item.type == 'outflow' %}
            <span class="text-danger">- {{ item.amount|default(0) / 100|currency }}</span>
          {% endif %}
        </td>
        <td>{{ item.user_balance|default(0) / 100|currency }}</td>
        <td>
          {% if item.action == 'recharge' %}
            {{ 'admin_v2.app_center.resource_settlement.balance.recharge_manually'|trans }}
          {% elseif item.action == 'purchase' %}
            {{ 'admin_v2.app_center.resource_settlement.balance.balance_payment'|trans }}
          {% elseif item.action == 'refund' %}
            {{ 'admin_v2.app_center.resource_settlement.balance.balance_refund'|trans }}
          {% endif %}
        </td>
        <td>
          <a href="#modal" data-toggle="modal"
             data-url="{{ path('admin_v2_resource_settlement_balance_modal', {id:item.id}) }}">{{ 'site.btn.detail'|trans }}</a>
        </td>
      </tr>
    {% else %}
      <tr>
        <td colspan="20">
          <div class="empty">{{ 'admin_v2.app_center.resource_settlement.empty'|trans }}</div>
        </td>
      </tr>
    {% endfor %}
    </tbody>
  </table>

  {{ admin_macro.paginator(paginator) }}

{% endblock %}